#include<bits/stdc++.h>
using namespace std;
int main(){
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    int n,m,x; cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>x;
    for(int i=1;i<=m;i++) cin>>x;
    int T; cin>>T;
    while(T--){
        cin>>x>>x>>x>>x;
        cout<<1<<endl;
    }
    return 0;
}
